#!/bin/bash
echo "当前构建版本号："${Tag}
echo "刷新系统环境变量..."
source /etc/profile
echo "跳过单元测试构建工程..."
gradle clean build -i -x test --no-daemon -Dprofile=pro -b build.gradle
echo "删除本地镜像库镜像Tag..."
# imageId=docker images | grep "mmp" | awk "{print $3}"
#docker rmi -f $(docker images | grep "mmp" | awk "{print $3}")
docker rmi -f harbor.hoofungson.cn/other/mmp:${Tag}
echo "构建Docker镜像..."
docker build -t harbor.hoofungson.cn/other/mmp:${Tag} .
echo "推送Docker本地镜像到远程私有镜像库..."
docker push harbor.hoofungson.cn/other/mmp:${Tag}
echo "开始自动化发布..."
# ansible-playbook /root/mytest.yml
sed -i "s/mmp\:.*\"/mmp\:${Tag}\"/g" /opt/docker/update_mmp_workload.json
sh /opt/docker/deploy.sh
echo "构建作业完成！！"